﻿using HZU.ZP.Data.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace HZU.ZP.Data.Help
{
    public class MessageComparer : IEqualityComparer<Message>
    {
        public bool Equals(Message x, Message y)
        {
            if (x == null || y == null)
                return false;
            if ((x.FromEmail == y.FromEmail && x.ToEmail == y.ToEmail) || (x.FromEmail == y.ToEmail && x.ToEmail == y.FromEmail))
                return true;
            else
                return false;
        }

        public int GetHashCode(Message message)
        {
            if (message == null) return 0;
            return message.FromEmail.GetHashCode() ^ message.ToEmail.GetHashCode();
        }
    }
}
